﻿#ifndef MEASUREPOLYLINE_H
#define MEASUREPOLYLINE_H

#include "MeasureElement.h"
namespace Qly {

class MeasureDataSet;

/**
 * @brief The MeasurePolyline class 折线总长度测量。
 *                            m_results_um[0] 是第一段线段的长度
 *                            m_results_um[1] 第二段线段的长度
 *                            m_results_um.last() 是总长
 *                            textTemplate 支持 @length_um, @length_mm, @length, @unit, @id 5 个关键字
 */
class MeasurePolyline: public MeasureElement
{
friend MeasureDataSet;
public:
    MeasurePolyline(MeasureDataSet *parent = nullptr);
    QString name() Q_DECL_OVERRIDE {return u8"折线长度";}
    int mouseLButtonPress(QPointF point_pix, QPointF point_um) Q_DECL_OVERRIDE;
    int mouseRButtonPress(QPointF point_pix, QPointF point_um) Q_DECL_OVERRIDE;
    int mouseMove(QPointF point_pix, QPointF point_um) Q_DECL_OVERRIDE;

private:
    void setStartPoint(QPointF point_pix, QPointF point_um);
    void setMidPoint(QPointF point_pix, QPointF point_um);
    void setTempEndPoint(QPointF point_pix, QPointF point_um);
    void setEndPoint(QPointF point_pix, QPointF point_um);
    void compute(void) Q_DECL_OVERRIDE; //计算图元的位置，还有长度结果
    void updateText(bool updatePosition = true) Q_DECL_OVERRIDE;
    void paint( QPainter &painter ) Q_DECL_OVERRIDE; //画方法

    QPointF m_tempEnd_um;
    QPointF m_tempEnd_pix;
};

}


#endif // MEASUREPOLYLINE_H
